const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            page: {
                ProvinceNumber: '',
                activeName: 'first',
                value1: '',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%,%%"))),
                ExtensionCondition: window.btoa(unescape(encodeURIComponent("AND article_exchange_address.VillageNumber IN (" + getCookie('village') + ")\r\n")))
            },
            str1: '',
            str: '',
        }
    },
    mounted() {

    },
    methods: {
        Treedata() {
            const _this = this;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                method: "post",
                data: {
                    SQLSerialNumber: 't_article_exchange_address',
                    Condition: window.btoa(unescape(encodeURIComponent("%%"))),
                    ExtensionCondition: window.btoa(unescape(encodeURIComponent("AND article_exchange_address.VillageNumber IN (" + getCookie('village') + ")\r\n"))),
                },
                success: (data) => {
                    this.treeData = data;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
            })
        },
        handleClick() {
            if (this.page.activeName == 'first') {
                this.str1 = '';
                this.page.Condition= window.btoa(unescape(encodeURIComponent("%"+this.str1+"%,%"+this.page.value1+"%,%"+this.page.ProvinceNumber+"%")));
            } else if (this.page.activeName == 'second') {
                this.str1 = '0';
                this.page.Condition= window.btoa(unescape(encodeURIComponent("%"+this.str1+"%,%"+this.page.value1+"%,%"+this.page.ProvinceNumber+"%")));
            } else if (this.page.activeName == 'three') {
                this.str1 = '2';
                this.page.Condition= window.btoa(unescape(encodeURIComponent("%"+this.str1+"%,%"+this.page.value1+"%,%"+this.page.ProvinceNumber+"%")));
            }
            this.postgetList(this.page);
        },
        handleNodeClick(data, node) {
            if (this.page.ProvinceNumber && this.page.ProvinceNumber == data.Article_Exchange_SerialNumber) {
                this.page.ProvinceNumber = '';
            } else {
                this.page.ProvinceNumber = data.Article_Exchange_SerialNumber;
            }
            console.log(this.page.ProvinceNumber);
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%" + this.page.ProvinceNumber + "%")))
            this.postgetList(this.page);
        },
        check() {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%" + this.page.ProvinceNumber + "%")))
            this.postgetList(this.page);
        },
        handle2(row){
            this.$confirm('是否'+ (row.Row_Status == '0'?'上架':'下架')+'该商品', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                let { TableName, primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
                    method: "post",
                    data: {
                        Data: TableName,
                        Condition: primary_key + "='" + row[primary_key] + "'"
                    },
                    success: (res) => {
                        if (res.length == 1) {
                            res[0].Row_Status = (row.Row_Status=='0'?'2':'0');
                            let lJSONObject_DataSet = new Object();
                            let lJSONObject_Table = new Object();
                            lJSONObject_Table[TableName] = res;
                            lJSONObject_DataSet['Modify'] = lJSONObject_Table;
                            let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
                            if (!lJSONObject_DataSet['Add']) {
                                lJSONObject_DataSet['Add'] = new Object();
                            }
                            lJSONObject_DataSet['Add']['base_operation_log'] = [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main,
                                Operation_Interface: "generalSave",
                                Operation_IP: getIpAddress()
                            }]
                            submitSave(lJSONObject_DataSet, (res) => {
                                if (res.Status == 'success') {
                                    this.postgetList(this.page);
                                } else {
                                    this.$message({
                                        type: 'error',
                                        message: '操作失败'
                                    });
                                }
                            })
                        } else {
                            this.$message({
                                type: 'error',
                                message: '操作失败'
                            });
                        }

                    },complete: (XMLHttpRequest) => {
                 
                        requestPretreatment(XMLHttpRequest);
                    }
                });
            }).catch(() => { });
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
